#!/usr/bin/python

import wx
import re
import fm
import os
import sys
import random

from debug  import here
from base   import *

settings=fm.settings

settings['paragraph_height']=6

settings['textbar.decor.bg']=wx.Colour(240,240,240)

settings['margin_marker_width']=8

settings['modification.saved_color']=wx.Colour(102,102,255)
settings['modification.unsaved_color']=wx.Colour(0,199,99)

settings['thumb.pen_color']=wx.Colour(220,129,0)


class Decoration:
	def __init__(me,textbar,doc):
		me.doc  = doc
		me.textbar = textbar
	def paint(me,dc,paragraphs,paragraphs_changed):
		pass
	
#settings['decor.sections.line_color']=fm.Gray(50)
settings['decor.sections.line_color']=fm.Gray(50)#wx.Colour(100,80,80)
settings['decor.sections.fill_color']=settings['decor.sections.line_color']#wx.Colour(100,80,80)
settings['decor.sections.line_width']=3

settings['decor.sections.line_vert']=False
settings['decor.sections.line_horz']=True

settings['decor.sections.gradient_show']=False
settings['decor.sections.gradient_start_color']=wx.Colour(200,200,200)
settings['decor.sections.gradient_end_color']=settings['textbar.decor.bg']

class Sections(Decoration):
	NORMAL,SECTION = range(2)
	
	def __init__(me,*args,**kwargs):
		Decoration.__init__(me,*args,**kwargs)
		
		me.line_state=[]
		
		me.pen=wx.Pen(settings['decor.sections.line_color'])#,settings['decor.sections.line_width'])
		#me.pen.SetCap(wx.CAP_BUTT)
		#me.pen=wx.Pen(me.settings['.line_color'],me.settings['.line_width'])
		
		me.brush=wx.Brush(settings['decor.sections.fill_color'])

		me.doc.EVT.LinesAdded.bind( me.on_lines_added )
		me.doc.EVT.LinesDeleted.bind( me.on_lines_deleted )
		me.doc.EVT.Opened.bind( me.on_opened )
		#me.doc.on('Opened', me.on_Opened)
		# me.doc.SIG_Opened.connect( me.on_opened )
		
		me.sections=[]
		me.clean = True
		
	def on_opened(me,e):
		me.on_lines_added(struct(src=e.src,first_added_line=0,N_lines_added=me.doc.text.GetLineCount()))
		
	def on_lines_added(me,e):
		me.line_state[e.first_added_line:e.first_added_line]=[me.NORMAL]*e.N_lines_added
		for i in range(e.first_added_line,e.first_added_line+e.N_lines_added):
			line=me.doc.text.GetLine(i)
				
			for pat in me.doc.mode.SECTION_PATTERNS:
				if re.match(pat,line):
					me.line_state[i]=me.SECTION
					me.clean=False
					break
		if not me.clean: me.textbar.Refresh()

	def on_lines_deleted(me,e): # ?? deleted section don't disappear
		for i in range(e.first_deleted_line,e.first_deleted_line+e.N_lines_deleted):
			if me.line_state[i]<>me.NORMAL:
				me.clean=False
				break
		me.line_state[e.first_deleted_line:e.first_deleted_line+e.N_lines_deleted]=[]
		if not me.clean: me.textbar.Refresh()
		
	def resection(me,pars):
		# -- 1st pass, figure out section type of each paragraph
		par_types = []
		for par in pars:
			par_type=me.NORMAL
			for i in par.lines:
				if i>=len(me.line_state):# ?? this shouldn't happen, does it ?
					continue 
				if me.line_state[i]==me.SECTION:
					par_type=me.SECTION
					break
			par_types.append(par_type)
		
		# -- 2nd pass, extend sections to span normal paragraphs
		def local_emit_end_of_section_prev(end):
			if sections==[]: return
			sections[-1].size=end-sections[-1].start+1
			
		n=len(par_types)
		sections=[]
		for i in range(n):
			if par_types[i]==me.NORMAL: continue
			local_emit_end_of_section_prev(i-1)
			sections.append( struct(start=i,type=par_types[i]) )
		local_emit_end_of_section_prev(n-1)
		
		return sections


	def paint(me,dc,paragraphs,pars_changed):
		if not me.clean or pars_changed:
			me.sections=me.resection(paragraphs)
			me.clean=True
			
		w,h=me.textbar.GetClientSize()
		h_par=settings['paragraph_height']
			
		dc.SetPen(me.pen)
		dc.SetBrush(me.brush)

		#print me.line_state
		
		for section in me.sections:
				
			x=0
			y=section.start*h_par

				
			#dc.SetPen(me.pen)
			if 0:
				if settings['decor.sections.line_vert']:
					dc.DrawLine(x+2,y,x+2,y+section.size*h_par-h_par)
					dc.DrawLine(x+w-2,y,x+w-2,y+section.size*h_par-h_par)
				if settings['decor.sections.line_horz']: dc.DrawLine(x,y,x+w,y)
			
			if 1:
				dc.SetPen(me.pen)
				dc.SetBrush(me.brush)
				dc.DrawRectangle(x,y+h_par/6,w,2*(h_par-settings['spacing'])/3)

			if settings['decor.sections.gradient_show']:
				h_gradient=min(80,section.size*h_par/2)
				y_gradient=(section.start+section.size)*h_par-h_gradient
				dc.GradientFillLinear(wx.Rect(x,y_gradient,w,h_gradient),
					settings['decor.sections.gradient_start_color'],
					settings['decor.sections.gradient_end_color'],wx.NORTH)
								
			#dc.SetPen(wx.Pen(wx.Colour(150,150,150),2))
			#dc.DrawLine(x,y+2,x+w,y+2)
			
# ?? s / decor / textbar /g
settings['textbar.filename.show']=True
settings['textbar.filename.overlap_silhouette']=False
settings['textbar.filename.location']='top'
settings['textbar.filename.location :type']=('top','bottom')
settings['textbar.filename.min_extent']=70
settings['textbar.filename.spacing']=4
settings['textbar.filename.abbreviate']=True
settings['textbar.filename.abbreviate_if_longer_than']=15
settings['textbar.filename.abbreviate_ellipsis']='...'

settings['decor.filename.rect_if_inactive_and_saved']=False
settings['decor.filename.bg']=wx.Colour(20,20,20,60)
settings['decor.filename.fg']=wx.BLACK

settings['decor.filename.outline_if_active']=False
settings['decor.filename.outline_if_active.color']=wx.WHITE
settings['decor.filename.outline_if_active.width']=3

settings['decor.filename.padding']=5
settings['decor.filename.bg_shows_modification_status']=True
settings['decor.filename.alpha']=200
settings['decor.filename.underneath_if_active']=True
settings['decor.filename.hide_if_active']=False
settings['decor.filename.hide_if_scrolling']=True
settings['decor.filename.font_size']=12

settings['decor.filename.tilt']=fm.if_Mac_Unix_Win(True,False,False)

class Filename(Decoration):
	
	def __init__(me,*args,**kwargs):
		Decoration.__init__(me,*args,**kwargs)
		
		me.pen=wx.Pen(settings['decor.filename.bg'])
		me.brush=wx.Brush(settings['decor.filename.bg'])
		
		if settings['decor.filename.bg_shows_modification_status']:
			me.doc.events.Unsaved+=me.on_doc_unsaved
			me.doc.events.Saved+=me.on_doc_saved
		
	def on_doc_saved(me,e):
		if not settings['textbar.filename.show']:
			return
		me.textbar.Refresh()
		
	def on_doc_unsaved(me,e):
		if not settings['textbar.filename.show']:
			return
		me.textbar.Refresh()
		
	def draw_separate(me):
		if not settings['textbar.filename.show']:
			return False
		return not settings['textbar.filename.overlap_silhouette']
		
	def draw_on_top(me):
		if not (settings['textbar.filename.show'] and settings['textbar.filename.overlap_silhouette']):
			return False
			
		return not me.draw_on_bottom()
			
	def draw_on_bottom(me):
		if not (settings['textbar.filename.show'] and settings['textbar.filename.overlap_silhouette']):
			return False
			
		if not settings['decor.filename.underneath_if_active']:
			return False
						
		if me.textbar.active:
			return True
		else:
			return False
		
	def _update_filename(me):
		if me.doc.file is None:
			filename='<Untitled>'
		else:
			filename=os.path.basename(me.doc.file)
			
		if settings['textbar.filename.abbreviate']:
			maxlen=settings['textbar.filename.abbreviate_if_longer_than']
			if len(filename) > maxlen:
				half = maxlen/2
				filename = filename[:half]+settings['textbar.filename.abbreviate_ellipsis']+filename[-half:]
					
		filename=' '+filename+' '
		me.filename=filename
		
	def paint(me,dc):
		if not settings['textbar.filename.show']:
			return
			
		if me.textbar.active and settings['textbar.filename.overlap_silhouette'] and settings['decor.filename.hide_if_active']:
			return
			
		if me.textbar.thumb.moving and settings['textbar.filename.overlap_silhouette'] and settings['decor.filename.hide_if_scrolling']:
			return
			
		alpha=settings['decor.filename.alpha']
		if me.textbar.active:#me.textbar.thumb.moving:
			alpha/=2
		
		me._update_filename()
			
		BR,BL,TL,TR,Sin,height = me._get_draw_parameters(dc)
		
		height = height+settings['textbar.filename.spacing']

		#dc.GradientFillLinear(wx.Rect(0,0,me.textbar.w,height),settings['textbar.bg'],wx.WHITE,wx.NORTH)
		
		if settings['decor.filename.bg_shows_modification_status']:
			if me.doc.modified:
				color=settings['modification.unsaved_color']
			else:
				color=settings['modification.saved_color']
			color=add_transparency(color,alpha) # move color/pen/brush creation into constructor
			dc.SetPen(wx.Pen(color))
			dc.SetBrush(wx.Brush(color))
		else:
			dc.SetPen(me.pen)
			dc.SetBrush(me.brush)
			
		if me.textbar.active and settings['decor.filename.outline_if_active']:
			dc.SetPen(wx.Pen(settings['decor.filename.outline_if_active.color'],settings['decor.filename.outline_if_active.width']))
			
		if settings['decor.filename.rect_if_inactive_and_saved'] or me.textbar.active or me.doc.modified: 
			dc.DrawPolygon((BR,BL,TL,TR))
		
		dc.DrawRotatedText(me.filename,BL[0],BL[1],math.asin(Sin)*180./pi)
				
		if settings['textbar.filename.location']=='top':
			location=TOP
		elif settings['textbar.filename.location']=='bottom':
			location=BOTTOM
		else:
			assert settings['textbar.filename.overlap_silhouette']
			location = None

			
		return location,height
		
	def _get_draw_parameters(me,dc):
	
		W_bar,H_bar=me.textbar.GetClientSize()
		
		if settings['decor.filename.font_size']:
			font=dc.GetFont()
			font.SetPointSize(settings['decor.filename.font_size'])
			dc.SetFont(font) 
				
		W_text,H_text,descent,externalLeading=dc.GetFullTextExtent(me.filename)
		H_text=H_text+descent+externalLeading
		W_text+=2

		if settings['decor.filename.tilt']:
			Si,_=quadratic_formula(a=H_text**2+W_text**2,b=-2*W_bar*H_text,c=W_bar**2-W_text**2)
			if Si==None:
				Si=0
			Co=sqrt(1-Si**2)
			x0=0
		else:
			Si=1
			Co=0
			x0=(W_bar-H_text)/2.
			
		BR=(x0+H_text*Si, W_text*Si+H_text*Co) # bottom right
		BL=(x0, W_text*Si)
		TL=(x0+W_text*Co,0) # top left
		TR=(x0+W_text*Co+H_text,H_text*Co)
		
		height=BR[1]
		
		vertical_adjustment = 0
		
		if settings['textbar.filename.location']=='bottom':
			vertical_adjustment = H_bar - height
			#print vertical_adjustment
			
		if height < settings['textbar.filename.min_extent']:
			extra_space = settings['textbar.filename.min_extent']-height
			if settings['textbar.filename.location']=='bottom':
				extra_space = -1 * extra_space
			vertical_adjustment += extra_space
			height = settings['textbar.filename.min_extent']
			
		#print vertical_adjustment

		BR=(BR[0],BR[1]+vertical_adjustment)
		BL=(BL[0],BL[1]+vertical_adjustment)
		TR=(TR[0],TR[1]+vertical_adjustment)
		TL=(TL[0],TL[1]+vertical_adjustment)
			
		return BR,BL,TL,TR,Si,height

class Modification(Decoration):
	
	def __init__(me,*args,**kwargs):
		Decoration.__init__(me,*args,**kwargs)
		
		me.brush_for_saved     = wx.Brush(settings['modification.saved_color'])
		me.brush_for_unsaved   = wx.Brush(settings['modification.unsaved_color'])
		
		me.doc.events.Saved          += me.refresh
		me.doc.events.LinesAdded     += me.refresh
		me.doc.events.LineChanged    += me.on_line_changed
		me.doc.events.LinesDeleted   += me.refresh
		
	def refresh(me,e):
		me.textbar.Refresh()
		
	def on_line_changed(me,e):
		if e.line_modification_status_changed:
			me.textbar.Refresh()
			
	def paint(me,dc,paragraphs,pars_changed):
		W,_=me.textbar.GetClientSize()
		h=settings['paragraph_height']
		
		line_state=me.doc.get_lines_modification_status()
		
		dc.SetPen(wx.TRANSPARENT_PEN)
		for par in paragraphs:
			par_state=fm.UNCHANGED
			for i in par.lines:
				if i>=len(line_state):
					continue
				if line_state[i]==fm.SAVED:
					if par_state==fm.UNCHANGED:
						par_state=fm.SAVED
				elif line_state[i]==fm.UNSAVED:
					par_state=fm.UNSAVED
					
			if par_state==fm.UNCHANGED:
				continue
			
			dc.SetBrush(me.brush_for_unsaved if par_state==fm.UNSAVED else me.brush_for_saved)
			
			x=W-settings['margin_marker_width']
			w=settings['margin_marker_width']
			
			y=par.i*h	
			
			
			dc.DrawRectangle(x,y,w,h)
			
settings['decor.silhouette.keep_color_when_inactive']=True
settings['draw_graph']=False
settings['use_gradient']=False
settings['bitset_use_indent_length']=11
settings['pen_color_when_active']=wx.Colour(100,80,80)#fm.Gray(80)#wx.Colour(128,0,64)
settings['gradient_end_color']=fm.Gray(100)#random_color()
settings['brush_color_when_active']=brighten(settings['pen_color_when_active'],0.5)
settings['codegraph.rectangle_rounded_radius']=0.7

class Silhouette(Decoration):
	
	def __init__(me,*args,**kwargs):
		Decoration.__init__(me,*args,**kwargs)
		
		me.active  = True
		
		me.reconfigure()
				
	def reconfigure(me,e=None,init=False):
		me.pen     = wx.Pen(settings['pen_color_when_active'])
		me.brush   = wx.Brush(settings['brush_color_when_active'])
		
		me.pen_when_inactive     = wx.MEDIUM_GREY_PEN
		me.brush_when_inactive   = wx.MEDIUM_GREY_BRUSH
		
		if not init:
			me.textbar.Refresh()
		
	def paint(me,dc,paragraphs,pars_changed):
		if settings['decor.silhouette.keep_color_when_inactive'] or me.textbar.active:
			dc.SetBrush(me.brush)
			dc.SetPen(me.pen)
		else:
			dc.SetBrush(me.brush_when_inactive)
			dc.SetPen(me.pen_when_inactive)			

		if settings['draw_graph']:
			h=settings['paragraph_height']
			rite_side=[]
			left_side=[]
			
			for par in paragraphs:
				left_side.append((par.x,       par.i*h+h/2))
				rite_side.append((par.x+par.w, par.i*h+h/2))
			
			left_side.reverse()
			poly=rite_side
			poly.extend(left_side)
			
			dc.DrawPolygon(poly)
		else:
			for par in paragraphs:
				x=par.x
				w=par.w
				y=par.i*settings['paragraph_height']
				h=settings['paragraph_height']-settings['spacing']
				
				if w<settings['paragraph_min_width']:
					continue
					
				if settings['use_gradient']:
					dc.GradientFillLinear(wx.Rect(x,y,w,h),me.pen.GetColour(),settings['gradient_end_color'])
				else:
					if settings['codegraph.rectangle_rounded_radius']:
						dc.DrawRoundedRectangle(x,y,w,h,settings['codegraph.rectangle_rounded_radius'])
					else:
						dc.DrawRectangle(x,y,w,h)
	

settings['thumb.vert_line_if_moving']=False
settings['thumb.min_pixel_size']=20
settings['thumb.brush_color']=add_transparency(brighten(settings['thumb.pen_color'],0.5),150)
settings['thumb.bg_when_inactive']=brighten(settings['thumb.brush_color'],0.5)
settings['thumb.brush_color_when_moving']=wx.Colour(255,255,0,200)

class TextbarThumb:
	
	def __init__(me,textbar):
		me.textbar  = textbar
		me.moving     = False
		
		me.reconfigure()
		
	def reconfigure(me,e=None,init=False):
	 	me.pen                 = wx.Pen(settings['thumb.pen_color'],2)
		me.brush               = wx.Brush(settings['thumb.brush_color'])
		me.brush_when_moving   = wx.Brush(settings['thumb.brush_color_when_moving'])
		me.brush_when_inactive = wx.Brush(settings['thumb.bg_when_inactive'])
		
		if not init:
			me.textbar.Refresh()
		
		
	def paint(me,dc,position,size,N_lines,N_pixels):
		
		if size>=N_lines:
			return
			
		if position+size>N_lines:
			position=N_lines-size
			
		
		to_pixels=N_pixels/float(N_lines)
		
		w=me.textbar.w
		H=me.textbar.h_decor
		
		h=size*to_pixels
		h=max(h,settings['thumb.min_pixel_size'])
		y=position*to_pixels
		x=0
		#w=2*w/3 # ?? calculate from actual text width
		
		dc.SetBrush(me.brush_when_moving if me.moving else me.brush if not me.textbar.active else me.brush_when_inactive) # ?? fix prefs, names of colors flipped
		dc.SetPen(me.pen if me.moving or me.textbar.active else wx.TRANSPARENT_PEN)
		dc.DrawRectangle(x,y,w,h)
		
		if me.moving:
			dc.DrawLine(x,y,x+w,y+h)
			dc.DrawLine(x+w,y,x,y+h)
		
		if settings['thumb.vert_line_if_moving'] and (me.moving or me.textbar.active):
			dc.DrawLine(x+w/2,0,x+w/2,y)
			dc.DrawLine(x+w/2,N_pixels,x+w/2,y+h)
			
settings['textbar.width']=30
settings['textbar.leftmargin']=2
settings['textbar.rightmargin']=2
settings['spacing']=2
settings['paragraph_min_width']=3
settings['indent_expansion']=1.
settings['textbar.decorations']=('Sections','Modification', 'Silhouette')
settings['clip.1_percent_cutoff']=95
settings['clip.2_cutoff_in_stddev']=5
settings['clip.warp_power']=1
settings['textbar.bg']=wx.Colour(220,220,220)
settings['color_border']=wx.BLACK
settings['color_border_when_scrolling']=wx.Colour(0,0,200)
settings['textbar.change_border_if_scrolling']=False

# ?? N_pixels - N_silhouette_pixels / N_paragraph_pixels
class Textbar(wx.Window):

	PAINT_DEFAULT,PAINT_DO_ALL,PAINT_MOVE_THUMB=range(3)

	def __init__(me,parent_doc,parent_panel):
		wx.Window.__init__(me,parent_panel,id=-1,size=(settings['textbar.width'],-1))
		
		me.Bind(wx.EVT_PAINT,           me.OnPaint)
		me.Bind(wx.EVT_LEFT_UP,         me.OnMouseLeftUp)
		me.Bind(wx.EVT_LEFT_DOWN,       me.OnMouseLeftDown)
		me.Bind(wx.EVT_MOTION,          me.OnMouseMotion)
		me.Bind(wx.EVT_ENTER_WINDOW,    me.OnMouseEnterWindow)		me.Bind(wx.EVT_LEAVE_WINDOW,    me.OnMouseLeaveWindow)
		me.Bind(wx.EVT_KILL_FOCUS,      me.OnKillFocus)
		
		me.events            = fm.EventSet('Scroll','Activate')
		
		me.doc               = parent_doc
		me.thumb             = TextbarThumb(me)
		me.active            = True
		me.indents           = []
		me.lengths           = []
		me.N_lines           = 0
		me.paint_mode        = me.PAINT_DEFAULT
		me.N_visible_lines   = 0
		me.top_visible_line  = 0
		me.paragraph_recompute_guard=None
		
		me.reconfigure()

	def reconfigure(me,e=None,init=False):
		me.decorations                 = [eval(klass)(me,me.doc) for klass in settings['textbar.decorations']]
		me.bg_brush		               = wx.Brush(settings['textbar.decor.bg'])
		me.border_pen                  = wx.Pen(settings['color_border'])
		me.border_pen_when_scrolling   = wx.Pen(settings['color_border_when_scrolling'],3)
		if settings['textbar.filename.show']:
			me.filename_display=Filename(me,me.doc)
		else:
			me.filename_display=None

		me.SetOwnBackgroundColour(settings['textbar.bg'])
		
		if not init:
			me.Refresh()
		
	def set_line_dimensions(me,indents,lengths):
		assert len(indents)==len(lengths)
		me.N_lines=len(lengths)
		me.line_lengths = lengths
		me.line_indents = indents
		
	def reparagraph(me):
		height=me.h_decor

		if (height,me.N_lines)==me.paragraph_recompute_guard:
			return False
		
		if me.N_lines==0:
			return False
			
		me.paragraph_recompute_guard=(height,me.N_lines)
		
		# 1/4 - break up into paragraphs
		
		me.N_paragraphs=int(floor(height/float(settings['paragraph_height'])))
		me.N_paragraphs=min(me.N_paragraphs,me.N_lines)
		me.N_pixels=me.N_paragraphs*(settings['paragraph_height'])
		
		me.paragraphs=[]
		
		cur_par=struct(lines=[],i=0)
		
		paragraph_FROM_line=me.N_paragraphs/float(me.N_lines)		
		for i in range(me.N_lines):
			paragraph_nr=floor(i*paragraph_FROM_line)
			if paragraph_nr<>cur_par.i:
				assert paragraph_nr==cur_par.i+1,(paragraph_nr,paragraph_FROM_line,me.N_paragraphs,me.N_lines)
				me.paragraphs.append(cur_par)
				cur_par=struct(lines=[],i=paragraph_nr)
			cur_par.lines.append(i)
		me.paragraphs.append(cur_par)
		
		# 2/4 - compute paragraph dimensions from the constituent lines
		
		lengths=[]
		indents=[]
		for par in me.paragraphs:
			sum_lines_length=0
			sum_lines_indent=0
			for i in par.lines:
				sum_lines_length+=me.line_lengths[i]
				sum_lines_indent+=me.line_indents[i]
			n=float(len(par.lines))
			lengths.append(sum_lines_length/n)
			indents.append(sum_lines_indent/n)

		
		# 3/4 - clip length of paragraphs that are too long
		
		lengths=clip_by_order_statistics(lengths,settings['clip.1_percent_cutoff'])
		lengths=clip_by_stddev(lengths,settings['clip.2_cutoff_in_stddev'],settings['clip.warp_power'])
		#indents=clip(indents,settings['paragraph_length_limit_in_stddev'])
		
		# 4/4 - compute pixel coordinates of paragraphs
		
		float_max_par_length=max(lengths)
		float_max_par_indent=max(indents)
		
		float_max_par_length=max(1., float_max_par_length)
		float_max_par_indent=max(1., float_max_par_indent)
		
		xorigin=settings['textbar.leftmargin']
		width=settings['textbar.width']-settings['textbar.rightmargin']-xorigin
		
		for i in range(me.N_paragraphs):
			if settings['bitset_use_indent_length']==11:
				x=xorigin+settings['indent_expansion'] * width *indents[i]/float_max_par_length # ?? better padding than +1
				w=width * lengths[i]/float_max_par_length - x
			elif settings['bitset_use_indent_length']==10:
				x=xorigin
				w=width * indents[i]/float_max_par_indent-1
			elif settings['bitset_use_indent_length']==1:
				x=xorigin
				w=width * lengths[i]/float_max_par_length - x 
			else:
				assert 0,'??'
			
			#if w<>0:w = max(w,settings['paragraph_min_width'])
			
			me.paragraphs[i].x=x
			me.paragraphs[i].w=w
			
		return True
		
		
	def OnPaint(me, e):
		if me.N_lines==0:
			return
			
		pdc = wx.PaintDC(me)
		
		try:      dc = wx.GCDC(pdc)
		except:   dc = pdc
			
		w,h = me.GetClientSize()
		
		me.w,me.h = w,h
		
		me.h_decor = me.h
		me.y_origin_decor = 0
		
		
		if me.filename_display.draw_separate():
			location,h_filename = me.filename_display.paint(dc)
			me.h_decor = me.h - h_filename
			if location==TOP:
				me.y_origin_decor = h_filename				
			dc.SetDeviceOrigin(0,me.y_origin_decor)
			
		paragraphs_changed = me.reparagraph()
			
		# - background
		dc.SetPen(wx.TRANSPARENT_PEN)
		dc.SetBrush(me.bg_brush)
		dc.DrawRectangle(0,0,w,me.N_pixels)

		# - line on bottom silhouette smaller than allocated size
		# ?? move this line drawing in case of filename on bottom info Filename
		if me.N_paragraphs==me.N_lines or settings['textbar.filename.location']=='bottom':
			dc.SetPen(wx.BLACK_PEN)
			dc.DrawLine(0,me.N_pixels,w,me.N_pixels)
	
		# - decorations
		if 1:
			# ?? move this line drawing in case of filename on bottom info Filename
			dc.SetPen(wx.BLACK_PEN)
			dc.DrawLine(0,-2,w,-2)
			
			if me.filename_display.draw_on_bottom(): me.filename_display.paint(dc)
				
			for d in me.decorations: d.paint(dc,me.paragraphs,paragraphs_changed)
			
			if me.filename_display.draw_on_top():   me.filename_display.paint(dc)
			
		# - thumb
		if 1:
			me.thumb.paint(dc,me.top_visible_line,me.N_visible_lines,me.N_lines,me.N_pixels)

		me.paint_mode=me.PAINT_DEFAULT
	
	def Refresh(me,eraseBackground=True,rect=None):		me.paint_mode=me.PAINT_DO_ALL		wx.Window.Refresh(me,eraseBackground,rect)
		
	def refresh_thumb(me):
		if me.paint_mode==me.PAINT_DO_ALL:
			return # ?? already must be a paint event pending, should we call Refresh just in case ?
		me.paint_mode=me.PAINT_MOVE_THUMB
		wx.Window.Refresh(me)

	def center_thumb_on_pixel(me,x,y):
		if me.N_lines==0:
			return
		line_nr=(y-me.y_origin_decor)*me.N_lines/float(me.N_pixels)
		if line_nr < 0:
			return
		me.events.Scroll(src=me,line=line_nr) # textbar will get this, call us back and move us
		
	
	def activate(me,val=True):
		me.active=val
		if not me.active:
			me.thumb.moving=False
		me.Refresh()
		
	# - wx event handlers (other than paint)
	
	def OnMouseLeftUp(me,e):
		x,y=e.GetPositionTuple()
		me.center_thumb_on_pixel(x,y)
		me.thumb.moving=True
		e.Skip()
		
	def OnMouseLeftDown(me,e):
		if me.active:return
		me.events.Activate(src=me)
		#?? put in ability to veto this
		me.activate()
		
	def OnMouseMotion(me,e):
		if not me.active or not me.thumb.moving:
			return
		x,y=e.GetPositionTuple()
		me.center_thumb_on_pixel(x,y)
		
	def OnKillFocus(me,e):
		me.thumb.moving=False
	
	def OnMouseEnterWindow(me,e):
		return
		if not me.active:
			return
		me.thumb.moving=True
		
	def OnMouseLeaveWindow(me,e):
		if not me.active or not me.thumb.moving:
			return
		
		me.thumb.moving=False
		me.refresh_thumb()
		
	# - </wx event handlers>
	
if __name__=='__main__': #testbed for the silhouette
	Data=[
		#top.py
		[(0, 18), (0, 1), (0, 19), (0, 4), (0, 1), (0, 8), (4, 106), (0, 4), (0, 1), (0, 4), (0, 36), (4, 109), (0, 4), (0, 1), (0, 24), (0, 1), (0, 16), (4, 5), (4, 33), (4, 15), (4, 14), (4, 2), (4, 18), (4, 16), (4, 24), (4, 55), (4, 21), (4, 73), (4, 21), (4, 44), (4, 29), (4, 15), (4, 40), (4, 2), (4, 32), (4, 15), (4, 22), (4, 39), (4, 30), (4, 17), (4, 40), (4, 2), (4, 56), (4, 17), (4, 14), (4, 32), (4, 17), (4, 42), (4, 2), (4, 22), (4, 32), (4, 17), (4, 14), (4, 32), (4, 36), (4, 75), (4, 5), (0, 1), (4, 33), (8, 24), (12, 13), (12, 4), (4, 25), (8, 49), (8, 3), (4, 33), (8, 104), (8, 3), (4, 18), (8, 40), (12, 4), (0, 18), (0, 1), (4, 24), (8, 16), (8, 19), (8, 3), (4, 18), (8, 32), (8, 3), (4, 21), (8, 23), (8, 12), (4, 2), (4, 21), (8, 26), (12, 87), (8, 25), (12, 24), (8, 12), (12, 4), (4, 29), (8, 39), (8, 23), (12, 8), (16, 5), (4, 18), (8, 27), (0, 1), (0, 25), (4, 16), (4, 18)]
	    #_testbed_textbar.py
	    ,[(0, 18), (0, 1), (0, 7), (4, 903), (4, 903), (4, 903), (0, 2), (0, 1), (0, 21), (0, 45), (0, 1), (0, 24), (0, 21), (4, 2), (0, 32), (0, 1), (4, 10), (4, 15), (4, 15), (0, 1), (4, 26), (8, 57), (8, 36), (8, 18), (8, 3), (4, 46), (8, 36), (8, 21), (8, 21), (8, 26), (8, 47), (8, 3), (8, 3), (4, 21), (8, 23), (12, 10), (12, 4), (8, 22), (8, 3), (8, 29), (8, 24), (8, 3), (8, 30), (12, 48), (12, 42), (12, 57), (12, 23), (12, 29), (0, 1), (0, 27), (0, 1), (4, 26), (8, 31), (8, 3), (8, 33), (8, 19), (8, 25), (8, 3), (8, 59), (8, 3), (8, 37), (12, 29), (12, 50), (8, 3), (0, 27), (0, 1), (4, 19), (12, 4), (8, 36), (8, 23), (0, 1), (0, 5), (4, 44), (4, 70), (4, 12), (0, 19), (4, 6), (4, 2), (0, 43), (0, 13), (0, 29)]
		#pickle.py
		,[(0, 65), (0, 1), (0, 55), (0, 69), (0, 54), (0, 1), (0, 9), (0, 1), (4, 12), (4, 14), (0, 1), (0, 11), (0, 1), (4, 23), (4, 28), (4, 25), (4, 28), (0, 1), (0, 16), (0, 1), (4, 16), (4, 19), (4, 23), (0, 1), (0, 4), (0, 1), (0, 56), (0, 1), (0, 20), (0, 36), (0, 79), (0, 15), (0, 11), (0, 14), (0, 10), (0, 1), (0, 73), (11, 58), (0, 1), (0, 54), (0, 71), (0, 62), (22, 69), (22, 62), (22, 73), (22, 53), (22, 74), (0, 1), (0, 70), (0, 20), (0, 21), (0, 1), (0, 61), (0, 69), (0, 55), (0, 23), (0, 1), (0, 30), (4, 65), (4, 9), (0, 1), (0, 34), (4, 76), (4, 19), (0, 1), (4, 8), (4, 9), (0, 1), (0, 36), (4, 78), (4, 34), (0, 1), (4, 79), (4, 76), (4, 20), (0, 1), (4, 8), (4, 9), (0, 1), (0, 73), (0, 72), (0, 24), (4, 31), (8, 27), (0, 1), (0, 64), (0, 5), (4, 44), (0, 20), (4, 23), (0, 1), (0, 72), (0, 5), (4, 16), (0, 18), (4, 23), (0, 1), (0, 71), (0, 68), (0, 38), (0, 1), (0, 59), (0, 54), (0, 53), (0, 71), (0, 51), (0, 69), (0, 72), (0, 52), (0, 51), (0, 61), (0, 51), (0, 36), (0, 78), (0, 73), (0, 68), (0, 69), (0, 70), (0, 78), (0, 78), (0, 77), (0, 60), (0, 65), (0, 77), (0, 56), (0, 42), (0, 70), (0, 76), (0, 76), (0, 54), (0, 76), (0, 62), (0, 42), (0, 54), (0, 71), (0, 71), (0, 71), (0, 53), (0, 63), (0, 43), (0, 72), (0, 67), (0, 1), (0, 75), (0, 75), (0, 1), (0, 13), (0, 1), (0, 53), (0, 77), (0, 78), (0, 52), (0, 52), (0, 57), (0, 71), (0, 73), (0, 38), (0, 39), (0, 55), (0, 49), (0, 1), (0, 56), (0, 1), (0, 1), (0, 69), (0, 6), (0, 1), (0, 1), (0, 21), (0, 1), (0, 15), (0, 1), (4, 45), (8, 75), (0, 1), (8, 68), (8, 70), (8, 71), (8, 67), (8, 71), (8, 71), (8, 34), (0, 1), (8, 68), (8, 40), (0, 1), (8, 67), (8, 71), (8, 68), (8, 18), (0, 1), (8, 76), (8, 73), (8, 70), (0, 1), (8, 12), (8, 29), (12, 25), (8, 25), (12, 40), (8, 52), (12, 81), (8, 32), (8, 23), (8, 35), (8, 33), (8, 22), (0, 1), (4, 26), (8, 40), (0, 1), (8, 72), (8, 74), (8, 75), (8, 27), (0, 1), (8, 12), (8, 26), (0, 1), (4, 25), (8, 70), (8, 28), (12, 48), (8, 23), (8, 25), (0, 1), (4, 28), (8, 43), (0, 1), (8, 74), (8, 77), (8, 64), (8, 72), (8, 71), (8, 20), (0, 1), (8, 73), (8, 79), (8, 71), (8, 77), (8, 48), (8, 22), (12, 19), (8, 40), (8, 34), (8, 39), (8, 43), (0, 1), (4, 73), (4, 40), (8, 21), (12, 24), (16, 39), (12, 18), (16, 51), (0, 1), (8, 36), (0, 1), (4, 73), (4, 40), (8, 21), (12, 24), (16, 39), (12, 18), (16, 51), (0, 1), (8, 36), (0, 1), (4, 25), (8, 58), (8, 38), (8, 16), (12, 32), (12, 19), (0, 1), (8, 25), (8, 35), (8, 14), (12, 39), (12, 19), (0, 1), (8, 40), (8, 22), (8, 33), (8, 14), (12, 66), (12, 19), (0, 1), (8, 76), (8, 13), (12, 43), (8, 73), (12, 21), (8, 17), (12, 34), (12, 19), (0, 1), (8, 40), (8, 39), (8, 19), (12, 29), (8, 14), (12, 72), (12, 57), (12, 23), (16, 40), (12, 18), (16, 58), (16, 27), (20, 34), (16, 22), (20, 71), (40, 59), (0, 1), (8, 74), (8, 35), (12, 38), (12, 19), (0, 1), (8, 48), (8, 38), (12, 75), (0, 1), (8, 63), (8, 20), (8, 30), (12, 66), (32, 65), (0, 1), (8, 66), (8, 39), (0, 1), (4, 34), (8, 52), (8, 20), (0, 1), (4, 30), (8, 41), (8, 21), (12, 27), (12, 34), (8, 14), (12, 49), (0, 1), (4, 50), (20, 63), (8, 48), (0, 1), (8, 46), (8, 44), (12, 72), (0, 1), (8, 39), (8, 31), (12, 71), (0, 1), (8, 25), (8, 27), (0, 1), (8, 76), (8, 78), (12, 67), (12, 64), (12, 71), (12, 66), (12, 68), (12, 66), (12, 66), (12, 27), (12, 14), (12, 42), (12, 49), (12, 14), (12, 71), (12, 70), (12, 66), (12, 69), (12, 64), (12, 71), (12, 71), (12, 57), (12, 14), (12, 70), (12, 64), (12, 67), (12, 69), (12, 27), (12, 26), (12, 44), (16, 37), (20, 67), (12, 61), (16, 37), (20, 72), (12, 28), (12, 22), (12, 23), (12, 26), (8, 14), (12, 23), (12, 23), (12, 26), (0, 1), (8, 28), (12, 30), (0, 1), (8, 68), (8, 68), (8, 69), (8, 66), (0, 1), (8, 34), (12, 43), (0, 1), (8, 34), (12, 44), (0, 1), (8, 30), (12, 24), (12, 25), (0, 1), (4, 73), (0, 1), (4, 18), (0, 1), (4, 30), (8, 25), (4, 35), (0, 1), (4, 30), (8, 28), (12, 52), (8, 14), (12, 46), (4, 31), (0, 1), (4, 47), (8, 21), (12, 76), (12, 72), (12, 20), (12, 53), (12, 25), (16, 32), (20, 51), (20, 27), (16, 34), (20, 71), (20, 27), (12, 49), (12, 73), (12, 50), (16, 70), (16, 47), (16, 53), (16, 23), (8, 70), (8, 43), (4, 33), (0, 1), (4, 48), (8, 28), (12, 37), (12, 27), (12, 24), (16, 51), (12, 18), (16, 58), (12, 19), (8, 44), (4, 35), (0, 1), (4, 49), (8, 21), (12, 51), (8, 14), (12, 49), (4, 37), (0, 1), (4, 50), (8, 21), (12, 25), (12, 24), (16, 59), (12, 18), (16, 60), (8, 14), (12, 50), (8, 26), (4, 39), (0, 1), (4, 51), (8, 21), (12, 43), (12, 30), (12, 62), (8, 14), (12, 47), (12, 47), (12, 74), (8, 26), (4, 41), (0, 1), (4, 34), (8, 34), (8, 54), (12, 38), (0, 1), (12, 25), (16, 28), (20, 46), (16, 29), (16, 44), (20, 63), (16, 22), (20, 38), (20, 32), (24, 57), (20, 26), (24, 56), (12, 18), (16, 28), (20, 55), (20, 55), (20, 59), (20, 53), (16, 22), (20, 58), (12, 30), (8, 43), (0, 1), (4, 31), (8, 27), (8, 27), (0, 1), (8, 21), (8, 19), (12, 22), (16, 35), (12, 18), (16, 36), (12, 19), (0, 1), (8, 25), (8, 25), (8, 34), (12, 32), (16, 30), (12, 57), (12, 32), (16, 49), (16, 37), (12, 18), (16, 42), (16, 34), (12, 19), (0, 1), (8, 75), (8, 36), (8, 20), (8, 28), (12, 26), (0, 1), (8, 28), (12, 74), (12, 73), (12, 76), (12, 71), (12, 75), (12, 74), (12, 49), (12, 45), (12, 22), (16, 38), (12, 56), (16, 41), (12, 19), (0, 1), (8, 24), (8, 26), (8, 26), (0, 1), (4, 37), (0, 1), (4, 75), (4, 76), (4, 20), (4, 37), (8, 32), (0, 1), (4, 30), (8, 27), (0, 1), (8, 21), (12, 30), (8, 50), (12, 31), (0, 1), (8, 26), (8, 39), (0, 1), (4, 35), (0, 1), (4, 77), (4, 28), (4, 22), (0, 1), (4, 37), (8, 47), (8, 25), (8, 27), (0, 1), (8, 25), (12, 28), (16, 24), (16, 30), (12, 19), (0, 1), (8, 36), (8, 33), (12, 21), (12, 24), (16, 21), (20, 37), (20, 34), (16, 38), (20, 33), (20, 26), (12, 25), (12, 22), (16, 28), (16, 30), (20, 28), (16, 31), (12, 20), (16, 29), (16, 30), (12, 48), (0, 1), (4, 30), (8, 27), (0, 1), (8, 21), (12, 30), (8, 50), (12, 31), (0, 1), (8, 26), (8, 46), (0, 1), (4, 41), (4, 32), (8, 42), (0, 1), (4, 38), (8, 65), (8, 25), (8, 27), (0, 1), (8, 25), (12, 31), (16, 24), (16, 24), (16, 31), (12, 19), (0, 1), (8, 36), (8, 33), (12, 21), (12, 24), (16, 21), (20, 45), (16, 38), (20, 33), (20, 26), (12, 25), (12, 22), (16, 28), (16, 33), (20, 28), (20, 28), (16, 32), (12, 20), (16, 30), (16, 24), (16, 24), (16, 31), (12, 48), (0, 1), (4, 30), (8, 28), (0, 1), (8, 26), (8, 27), (8, 26), (0, 1), (8, 44), (12, 41), (12, 51), (12, 36), (8, 14), (12, 22), (0, 1), (8, 20), (0, 1), (8, 21), (12, 22), (12, 29), (16, 26), (12, 23), (8, 14), (12, 29), (16, 26), (12, 70), (0, 1), (8, 26), (0, 1), (8, 13), (12, 40), (8, 31), (12, 33), (8, 14), (12, 31), (12, 37), (8, 20), (8, 21), (0, 1), (4, 39), (0, 1), (4, 61), (8, 27), (8, 25), (0, 1), (8, 25), (12, 32), (0, 1), (8, 50), (8, 27), (12, 44), (0, 1), (8, 13), (12, 31), (12, 38), (12, 39), (8, 56), (12, 33), (16, 61), (16, 37), (8, 14), (12, 33), (16, 37), (20, 75), (20, 41), (0, 1), (8, 28), (12, 59), (12, 21), (16, 32), (16, 33), (20, 44), (16, 37), (20, 65), (16, 22), (20, 51), (16, 23), (0, 1), (8, 52), (8, 26), (0, 1), (4, 38), (4, 41), (4, 48), (4, 37), (0, 1), (0, 19), (0, 1), (0, 26), (4, 54), (0, 1), (4, 53), (4, 55), (4, 31), (4, 61), (4, 58), (4, 23), (4, 8), (4, 9), (8, 33), (4, 21), (8, 41), (8, 27), (0, 1), (0, 1), (0, 70), (0, 46), (0, 1), (0, 60), (0, 1), (0, 33), (4, 57), (0, 1), (4, 39), (4, 23), (4, 26), (4, 56), (4, 8), (4, 75), (4, 44), (4, 24), (8, 19), (4, 25), (8, 30), (0, 1), (4, 45), (8, 27), (12, 50), (8, 75), (12, 18), (4, 10), (8, 26), (4, 26), (4, 16), (0, 1), (0, 1), (0, 23), (0, 1), (0, 17), (0, 1), (4, 30), (8, 75), (0, 1), (8, 76), (8, 34), (0, 1), (8, 73), (8, 76), (8, 73), (8, 75), (8, 62), (8, 12), (8, 38), (8, 30), (8, 23), (0, 1), (4, 20), (8, 68), (0, 1), (8, 73), (8, 12), (8, 53), (8, 24), (8, 40), (8, 25), (8, 33), (8, 13), (12, 21), (16, 30), (16, 36), (8, 32), (12, 34), (0, 1), (4, 67), (4, 73), (4, 75), (4, 74), (4, 70), (4, 72), (4, 77), (4, 28), (4, 22), (8, 27), (8, 25), (8, 25), (8, 44), (8, 17), (0, 1), (4, 18), (0, 1), (4, 24), (8, 23), (4, 28), (0, 1), (4, 26), (8, 34), (8, 32), (12, 72), (4, 33), (0, 1), (4, 27), (8, 35), (8, 47), (4, 35), (0, 1), (4, 30), (8, 31), (8, 47), (4, 41), (0, 1), (4, 25), (8, 26), (4, 31), (0, 1), (4, 26), (8, 27), (4, 36), (0, 1), (4, 25), (8, 26), (4, 34), (0, 1), (4, 24), (8, 31), (8, 30), (12, 24), (8, 31), (12, 23), (8, 14), (12, 17), (16, 32), (12, 31), (16, 33), (8, 25), (4, 29), (0, 1), (4, 27), (8, 48), (4, 35), (0, 1), (4, 28), (8, 39), (4, 37), (0, 1), (4, 28), (8, 61), (4, 37), (0, 1), (4, 25), (8, 51), (4, 31), (0, 1), (4, 26), (8, 30), (8, 29), (8, 40), (4, 33), (0, 1), (4, 26), (8, 39), (8, 29), (8, 40), (4, 33), (0, 1), (4, 26), (8, 49), (4, 33), (0, 1), (4, 51), (8, 51), (4, 39), (0, 1), (4, 27), (8, 35), (8, 49), (12, 34), (16, 40), (20, 63), (16, 42), (16, 22), (8, 14), (12, 55), (8, 49), (4, 35), (0, 1), (4, 30), (8, 41), (8, 36), (4, 41), (0, 1), (4, 28), (8, 72), (4, 37), (0, 1), (4, 31), (8, 41), (8, 53), (4, 43), (0, 1), (4, 36), (8, 32), (8, 36), (4, 53), (0, 1), (4, 26), (8, 26), (8, 51), (4, 33), (0, 1), (4, 32), (8, 30), (4, 45), (0, 1), (4, 27), (8, 43), (4, 35), (0, 1), (4, 27), (8, 61), (4, 35), (0, 1), (4, 27), (8, 77), (4, 35), (0, 1), (4, 31), (8, 30), (4, 43), (0, 1), (4, 37), (8, 30), (4, 49), (0, 1), (4, 25), (8, 26), (8, 44), (4, 31), (0, 1), (4, 25), (8, 26), (8, 15), (8, 33), (8, 42), (12, 27), (12, 31), (12, 27), (8, 29), (4, 31), (0, 1), (4, 73), (4, 73), (4, 51), (4, 74), (4, 68), (4, 38), (8, 39), (8, 27), (8, 25), (8, 25), (16, 45), (16, 56), (12, 17), (16, 38), (16, 40), (16, 33), (12, 33), (16, 75), (16, 29), (16, 21), (8, 29), (12, 17), (16, 37), (12, 35), (16, 65), (20, 65), (8, 27), (0, 1), (4, 25), (8, 38), (8, 36), (8, 46), (8, 48), (4, 31), (0, 1), (4, 24), (8, 60), (8, 26), (8, 36), (8, 36), (4, 29), (0, 1), (4, 27), (8, 32), (8, 29), (8, 38), (8, 29), (4, 35), (0, 1), (4, 27), (8, 38), (8, 36), (8, 46), (8, 27), (4, 35), (0, 1), (4, 25), (8, 33), (8, 33), (4, 31), (0, 1), (4, 25), (8, 55), (8, 33), (4, 31), (0, 1), (4, 25), (8, 42), (8, 33), (4, 31), (0, 1), (4, 35), (8, 17), (8, 46), (8, 27), (12, 29), (12, 19), (8, 43), (8, 20), (12, 70), (8, 36), (8, 37), (8, 25), (0, 1), (4, 40), (8, 39), (8, 27), (8, 34), (8, 35), (8, 21), (0, 1), (4, 27), (8, 27), (8, 27), (8, 25), (8, 28), (8, 26), (4, 35), (0, 1), (4, 24), (8, 27), (4, 29), (0, 1), (4, 29), (8, 26), (8, 27), (4, 39), (0, 1), (4, 24), (8, 36), (4, 29), (0, 1), (4, 24), (8, 53), (4, 29), (0, 1), (4, 27), (8, 30), (8, 40), (4, 35), (0, 1), (4, 32), (8, 39), (8, 40), (4, 45), (0, 1), (4, 24), (8, 57), (4, 29), (0, 1), (4, 27), (8, 30), (8, 44), (4, 35), (0, 1), (4, 32), (8, 39), (8, 44), (4, 45), (0, 1), (4, 27), (8, 27), (8, 28), (8, 25), (8, 27), (4, 35), (0, 1), (4, 28), (8, 27), (8, 29), (8, 31), (8, 38), (8, 25), (4, 37), (0, 1), (4, 28), (8, 27), (8, 28), (8, 26), (8, 25), (8, 26), (4, 37), (0, 1), (4, 29), (8, 27), (8, 29), (8, 31), (8, 49), (12, 42), (0, 1), (8, 25), (4, 39), (0, 1), (4, 26), (8, 27), (8, 28), (8, 25), (8, 55), (8, 21), (12, 28), (12, 19), (8, 25), (8, 57), (12, 37), (8, 18), (12, 17), (16, 44), (12, 33), (16, 71), (16, 68), (16, 62), (16, 59), (16, 42), (16, 72), (16, 54), (16, 71), (16, 43), (16, 43), (20, 40), (8, 22), (12, 43), (16, 36), (4, 33), (0, 1), (4, 25), (8, 31), (4, 31), (0, 1), (4, 25), (8, 33), (8, 27), (4, 31), (0, 1), (0, 38), (0, 1), (0, 19), (4, 9), (0, 1), (0, 38), (0, 1), (0, 29), (0, 1), (0, 20), (4, 73), (4, 73), (4, 40), (0, 1), (4, 24), (4, 7), (4, 26), (4, 15), (4, 28), (4, 15), (4, 27), (4, 15), (4, 29), (4, 15), (4, 27), (4, 11), (4, 26), (4, 11), (4, 8), (4, 8), (0, 1), (4, 15), (8, 18), (4, 14), (8, 23), (8, 38), (8, 45), (8, 42), (8, 24), (12, 54), (12, 38), (8, 37), (12, 60), (12, 39), (4, 10), (8, 73), (8, 75), (8, 43), (8, 24), (8, 38), (8, 45), (8, 42), (8, 24), (12, 37), (12, 25), (8, 28), (8, 25), (8, 21), (8, 23), (8, 45), (8, 45), (8, 33), (12, 68), (8, 34), (12, 60), (12, 39), (0, 1), (4, 28), (8, 28), (4, 10), (8, 26), (4, 43), (4, 40), (4, 24), (0, 1), (0, 23), (4, 75), (0, 1), (4, 24), (4, 7), (4, 32), (4, 9), (4, 32), (4, 11), (4, 32), (4, 10), (4, 32), (4, 12), (4, 28), (4, 10), (4, 28), (4, 9), (4, 8), (0, 1), (4, 23), (4, 20), (8, 18), (4, 42), (4, 71), (4, 27), (8, 32), (4, 13), (0, 1), (0, 13), (0, 1), (0, 5), (4, 35), (0, 20), (4, 34), (0, 1), (0, 36), (4, 38), (0, 1), (0, 31), (4, 22), (4, 38), (4, 27), (0, 1), (0, 16), (4, 34), (0, 1), (0, 16), (4, 25), (4, 34), (0, 1), (0, 10), (0, 1), (0, 13), (4, 19), (4, 29), (0, 1), (0, 27), (4, 12)]
		#os.py
		,[(0, 73), (0, 1), (0, 14), (2, 75), (2, 64), (2, 61), (2, 74), (2, 75), (2, 77), (2, 54), (2, 64), (2, 60), (2, 76), (2, 58), (2, 71), (0, 1), (0, 65), (0, 65), (0, 67), (0, 61), (0, 24), (0, 4), (0, 1), (0, 3), (0, 1), (0, 11), (0, 1), (0, 34), (0, 1), (0, 48), (0, 70), (11, 49), (11, 47), (0, 1), (0, 31), (4, 9), (8, 36), (4, 27), (8, 55), (0, 1), (0, 22), (4, 19), (4, 19), (4, 24), (4, 9), (8, 32), (4, 24), (8, 13), (4, 29), (0, 1), (4, 17), (4, 45), (4, 14), (0, 1), (0, 21), (4, 16), (4, 21), (4, 21), (4, 9), (8, 29), (4, 24), (8, 13), (4, 26), (0, 1), (4, 14), (4, 42), (4, 11), (0, 1), (0, 22), (4, 17), (4, 21), (4, 22), (4, 9), (8, 30), (4, 24), (8, 13), (4, 42), (8, 30), (4, 10), (8, 34), (8, 35), (0, 1), (4, 15), (4, 43), (4, 12), (0, 1), (0, 22), (4, 17), (4, 19), (4, 22), (4, 9), (8, 30), (4, 24), (8, 13), (4, 27), (0, 1), (4, 15), (4, 43), (4, 12), (0, 1), (0, 21), (4, 16), (4, 21), (4, 21), (4, 9), (8, 29), (4, 24), (8, 13), (4, 44), (4, 26), (0, 1), (4, 14), (4, 42), (4, 11), (0, 1), (0, 25), (4, 20), (4, 19), (4, 25), (4, 9), (8, 33), (4, 24), (8, 13), (4, 30), (0, 1), (4, 18), (4, 46), (4, 15), (0, 1), (0, 6), (4, 53), (0, 1), (0, 30), (0, 76), (4, 13), (0, 1), (0, 11), (0, 1), (0, 68), (0, 52), (0, 13), (0, 13), (0, 13), (0, 1), (0, 3), (0, 1), (0, 29), (0, 61), (0, 1), (0, 31), (4, 36), (0, 1), (4, 68), (4, 69), (4, 71), (4, 15), (0, 1), (4, 8), (4, 34), (4, 17), (8, 38), (4, 48), (8, 29), (8, 80), (12, 19), (4, 22), (0, 1), (0, 22), (4, 24), (0, 1), (4, 68), (4, 66), (4, 70), (4, 64), (4, 70), (4, 67), (0, 1), (4, 8), (4, 16), (4, 34), (4, 17), (8, 38), (4, 25), (8, 13), (12, 24), (8, 22), (12, 18), (8, 38), (0, 1), (0, 23), (4, 25), (0, 1), (4, 70), (4, 67), (4, 66), (4, 69), (4, 70), (4, 61), (0, 1), (4, 71), (4, 67), (4, 10), (0, 1), (4, 8), (4, 33), (4, 48), (8, 23), (4, 21), (4, 33), (4, 22), (8, 13), (12, 29), (8, 22), (12, 17), (0, 1), (0, 54), (0, 1), (0, 43), (4, 33), (0, 1), (4, 74), (4, 58), (0, 1), (8, 37), (0, 1), (4, 75), (4, 73), (4, 76), (4, 78), (4, 73), (4, 45), (0, 1), (4, 73), (4, 76), (4, 75), (4, 66), (4, 58), (0, 1), (4, 75), (4, 77), (4, 77), (4, 70), (4, 76), (4, 72), (4, 15), (0, 1), (4, 66), (4, 69), (4, 68), (4, 71), (4, 67), (4, 48), (0, 1), (4, 72), (4, 71), (4, 71), (4, 12), (0, 1), (4, 13), (0, 1), (4, 38), (4, 55), (8, 32), (8, 66), (8, 60), (8, 26), (12, 62), (4, 8), (0, 1), (4, 44), (0, 1), (4, 70), (4, 68), (4, 70), (4, 72), (4, 49), (4, 9), (8, 69), (8, 31), (8, 29), (4, 23), (8, 32), (12, 25), (8, 15), (0, 1), (4, 27), (4, 23), (8, 35), (12, 30), (8, 14), (12, 33), (0, 1), (4, 16), (8, 33), (4, 22), (8, 31), (8, 29), (12, 51), (16, 24), (4, 20), (8, 33), (0, 1), (0, 23), (0, 1), (0, 40), (0, 5), (4, 12), (0, 18), (4, 17), (0, 1), (0, 24), (4, 26), (0, 1), (4, 71), (4, 25), (4, 22), (0, 1), (0, 25), (4, 32), (0, 1), (4, 60), (4, 56), (4, 19), (4, 33), (0, 1), (0, 25), (4, 27), (0, 1), (4, 68), (4, 64), (4, 23), (0, 1), (0, 26), (4, 33), (0, 1), (4, 68), (4, 71), (4, 17), (4, 19), (4, 34), (0, 1), (0, 24), (4, 25), (0, 1), (4, 68), (4, 60), (4, 48), (4, 25), (0, 1), (0, 30), (4, 32), (0, 1), (4, 68), (4, 64), (4, 21), (4, 48), (4, 30), (0, 1), (0, 73), (0, 1), (0, 36), (4, 38), (0, 1), (4, 24), (8, 22), (8, 30), (4, 10), (8, 21), (8, 26), (8, 22), (0, 1), (4, 34), (4, 13), (8, 29), (8, 15), (4, 22), (8, 30), (4, 10), (8, 26), (4, 34), (4, 21), (4, 20), (4, 21), (8, 40), (8, 13), (12, 37), (8, 25), (12, 35), (12, 57), (16, 40), (16, 30), (16, 30), (4, 18), (8, 41), (4, 23), (0, 1), (0, 61), (0, 5), (4, 42), (4, 11), (0, 18), (4, 9), (0, 6), (4, 20), (0, 1), (4, 34), (4, 34), (4, 38), (0, 1), (4, 30), (8, 27), (12, 28), (0, 1), (4, 25), (8, 68), (8, 43), (4, 73), (8, 42), (8, 51), (12, 41), (16, 49), (16, 33), (16, 45), (20, 40), (12, 46), (16, 34), (16, 46), (12, 40), (16, 46), (12, 17), (16, 25), (12, 30), (16, 44), (20, 47), (12, 18), (16, 44), (20, 34), (20, 47), (12, 36), (16, 48), (12, 41), (16, 48), (12, 46), (16, 59), (12, 51), (16, 25), (20, 25), (24, 43), (20, 43), (24, 47), (24, 42), (28, 40), (20, 26), (24, 35), (24, 61), (24, 45), (24, 39), (28, 46), (16, 27), (20, 40), (12, 28), (16, 34), (0, 1), (4, 51), (8, 51), (12, 41), (16, 49), (16, 36), (12, 46), (16, 34), (16, 38), (12, 52), (16, 25), (20, 25), (24, 43), (20, 43), (24, 47), (24, 42), (28, 40), (20, 26), (24, 35), (24, 61), (24, 45), (24, 39), (28, 46), (16, 27), (20, 40), (12, 17), (16, 25), (12, 30), (16, 21), (12, 18), (16, 44), (20, 34), (20, 39), (12, 28), (16, 34), (0, 1), (0, 1), (4, 32), (0, 1), (0, 31), (4, 69), (4, 70), (4, 37), (0, 25), (0, 1), (0, 19), (4, 9), (8, 19), (8, 20), (4, 22), (8, 21), (0, 1), (0, 43), (0, 67), (0, 1), (4, 15), (4, 29), (0, 1), (4, 68), (4, 66), (4, 19), (0, 1), (4, 48), (8, 63), (8, 21), (8, 20), (12, 20), (12, 17), (16, 32), (20, 37), (16, 22), (20, 42), (12, 20), (16, 27), (8, 14), (12, 21), (12, 33), (16, 64), (12, 21), (16, 44), (16, 36), (20, 29), (16, 39), (20, 42), (16, 37), (20, 44), (16, 22), (20, 70), (0, 1), (4, 34), (8, 47), (0, 1), (0, 55), (0, 51), (0, 71), (0, 67), (8, 56), (0, 1), (4, 40), (8, 53), (0, 1), (0, 63), (0, 23), (0, 51), (0, 71), (0, 67), (8, 56), (0, 1), (4, 59), (0, 1), (4, 35), (8, 48), (0, 1), (0, 67), (0, 22), (0, 51), (0, 71), (0, 67), (8, 57), (0, 1), (4, 41), (8, 54), (0, 1), (0, 67), (0, 52), (0, 51), (0, 71), (0, 67), (8, 57), (0, 1), (0, 22), (4, 54), (4, 46), (0, 1), (4, 35), (8, 48), (0, 1), (0, 55), (0, 51), (0, 71), (0, 67), (8, 40), (0, 1), (4, 36), (8, 54), (0, 1), (0, 63), (0, 22), (0, 51), (0, 71), (0, 67), (8, 23), (8, 51), (0, 1), (0, 1), (4, 64), (0, 1), (0, 1), (0, 23), (4, 59), (4, 42), (4, 36), (8, 49), (0, 1), (0, 67), (0, 52), (0, 51), (0, 71), (0, 67), (8, 41), (0, 1), (4, 37), (8, 55), (0, 1), (0, 67), (0, 52), (0, 51), (0, 71), (0, 67), (8, 23), (8, 52), (0, 1), (0, 1), (4, 68), (0, 1), (0, 1), (0, 32), (0, 20), (4, 30), (8, 47), (12, 81), (12, 82), (12, 84), (12, 81), (12, 84), (12, 70), (12, 26), (12, 56), (12, 33), (8, 33), (0, 1), (4, 30), (8, 47), (12, 81), (12, 82), (12, 84), (12, 81), (12, 84), (12, 84), (12, 26), (12, 64), (12, 41), (8, 33), (0, 1), (4, 30), (8, 47), (12, 81), (12, 82), (12, 84), (12, 81), (12, 84), (12, 77), (12, 26), (12, 56), (12, 33), (8, 33), (0, 1), (0, 29), (0, 1), (0, 34), (4, 34), (0, 1), (0, 29), (4, 35), (4, 37), (0, 1), (0, 5), (4, 74), (0, 46), (4, 9), (0, 1), (0, 37), (4, 37), (0, 1), (0, 32), (4, 35), (4, 40), (0, 1), (0, 5), (4, 61), (21, 43), (0, 49), (4, 9), (0, 1), (0, 27), (4, 20), (8, 29), (0, 1), (8, 74), (0, 1), (8, 12), (8, 13), (12, 56), (8, 35), (12, 80), (8, 19), (8, 30), (12, 54), (8, 26), (8, 21)]
		#dbg.py
		,[(0, 18), (0, 1), (0, 10), (0, 1), (0, 42), (3, 25), (3, 67), (0, 20)]
		#bzip2.c
		,[(0, 1), (0, 64), (0, 64), (0, 64), (0, 1), (0, 5), (2, 62), (2, 56), (0, 1), (2, 65), (0, 1), (2, 69), (2, 69), (2, 11), (0, 1), (2, 68), (5, 67), (0, 1), (2, 71), (5, 71), (5, 62), (5, 61), (0, 1), (2, 70), (5, 59), (0, 1), (2, 67), (5, 73), (5, 17), (0, 1), (2, 68), (2, 68), (2, 69), (2, 66), (2, 69), (2, 68), (2, 64), (2, 63), (2, 60), (2, 69), (2, 63), (0, 1), (2, 32), (2, 18), (2, 46), (0, 1), (2, 51), (5, 18), (5, 19), (5, 19), (5, 21), (5, 18), (5, 19), (5, 22), (5, 20), (0, 1), (2, 57), (0, 5), (0, 1), (0, 1), (0, 57), (0, 57), (0, 57), (0, 1), (0, 5), (3, 12), (6, 63), (6, 62), (6, 62), (6, 70), (6, 67), (6, 64), (6, 40), (0, 1), (3, 15), (6, 69), (6, 45), (0, 1), (6, 65), (6, 69), (6, 68), (6, 62), (6, 69), (6, 69), (6, 66), (6, 69), (6, 73), (6, 68), (6, 26), (0, 1), (6, 64), (6, 69), (6, 61), (0, 1), (3, 12), (6, 68), (6, 66), (6, 72), (6, 49), (0, 5), (0, 1), (0, 1), (0, 1), (0, 57), (0, 57), (0, 57), (0, 1), (0, 50), (0, 5), (2, 51), (0, 5), (0, 1), (0, 5), (2, 23), (2, 35), (2, 23), (0, 5), (0, 23), (0, 1), (0, 5), (2, 44), (2, 52), (2, 38), (2, 65), (2, 48), (0, 5), (0, 23), (0, 1), (0, 44), (0, 20), (0, 22), (0, 16), (0, 18), (0, 7), (0, 1), (0, 1), (0, 50), (0, 5), (2, 32), (0, 5), (0, 1), (0, 19), (0, 20), (0, 20), (0, 20), (0, 18), (0, 19), (0, 19), (0, 19), (0, 1), (0, 62), (0, 62), (0, 62), (0, 1), (0, 1), (0, 50), (0, 5), (3, 28), (0, 5), (0, 1), (0, 12), (0, 22), (0, 26), (0, 22), (0, 23), (0, 25), (0, 26), (0, 1), (0, 27), (0, 29), (0, 28), (0, 31), (0, 31), (0, 1), (0, 41), (6, 38), (0, 1), (0, 37), (6, 38), (0, 1), (0, 36), (0, 1), (0, 19), (0, 50), (0, 9), (0, 28), (0, 10), (0, 1), (0, 20), (0, 21), (0, 24), (0, 21), (0, 20), (0, 27), (0, 26), (0, 28), (0, 58), (8, 58), (11, 58), (34, 58), (11, 58), (8, 22), (0, 10), (0, 1), (0, 21), (0, 21), (0, 24), (0, 28), (0, 58), (8, 58), (11, 58), (34, 58), (11, 58), (8, 22), (0, 10), (0, 21), (0, 1), (0, 1), (0, 1), (0, 16), (0, 19), (0, 22), (0, 25), (0, 1), (0, 31), (0, 31), (0, 32), (0, 32), (0, 43), (0, 43), (0, 1), (0, 37), (6, 38), (0, 1), (0, 56), (6, 41), (0, 1), (0, 56), (6, 56), (9, 56), (32, 56), (9, 56), (6, 20), (0, 1), (0, 25), (0, 1), (0, 17), (0, 22), (0, 7), (0, 1), (0, 50), (0, 5), (2, 40), (0, 5), (0, 1), (0, 30), (0, 30), (0, 31), (0, 31), (0, 32), (0, 31), (0, 32), (39, 40), (0, 24), (0, 24), (0, 1), (0, 5), (2, 50), (2, 50), (0, 5), (0, 23), (0, 1), (0, 1), (0, 56), (0, 56), (0, 56), (0, 1), (0, 19), (0, 60), (0, 62), (0, 56), (0, 19), (0, 1), (0, 53), (0, 27), (0, 27), (0, 27), (0, 1), (0, 26), (0, 27), (0, 27), (0, 27), (0, 1), (0, 16), (0, 17), (0, 1), (0, 27), (0, 1), (0, 25), (0, 32), (0, 32), (0, 32), (0, 19), (0, 39), (0, 33), (0, 20), (0, 1), (0, 59), (0, 59), (0, 59), (0, 59), (0, 59), (0, 59), (0, 59), (0, 1), (0, 46), (0, 39), (0, 1), (0, 1), (0, 1), (0, 56), (0, 56), (0, 56), (0, 56), (0, 1), (0, 8), (3, 27), (3, 11), (0, 1), (0, 1), (0, 7), (0, 65), (0, 2), (3, 43), (3, 43), (3, 43), (3, 43), (3, 43), (3, 43), (3, 43), (3, 43), (0, 2), (0, 1), (0, 1), (0, 7), (0, 38), (0, 2), (3, 13), (3, 22), (3, 22), (3, 29), (6, 40), (6, 21), (3, 5), (3, 15), (0, 2), (0, 1), (0, 1), (0, 7), (0, 33), (0, 2), (3, 12), (3, 27), (6, 34), (3, 13), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 33), (0, 2), (3, 20), (3, 13), (3, 12), (3, 30), (6, 33), (6, 26), (6, 22), (3, 5), (3, 15), (0, 2), (0, 1), (0, 1), (0, 62), (3, 49), (0, 3), (0, 7), (0, 48), (0, 2), (3, 16), (3, 19), (3, 22), (3, 23), (3, 8), (6, 36), (6, 27), (6, 14), (3, 38), (3, 21), (3, 31), (6, 33), (0, 2), (0, 1), (0, 1), (0, 56), (0, 56), (0, 56), (0, 1), (0, 50), (0, 8), (0, 24), (0, 2), (3, 26), (3, 30), (3, 20), (3, 17), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 52), (0, 2), (3, 23), (3, 23), (3, 18), (3, 43), (3, 45), (3, 36), (0, 1), (3, 28), (3, 29), (0, 1), (3, 43), (3, 44), (0, 1), (3, 45), (27, 70), (3, 40), (0, 1), (3, 49), (0, 1), (3, 18), (0, 1), (6, 33), (6, 59), (6, 46), (6, 70), (6, 43), (0, 1), (3, 5), (0, 1), (3, 41), (24, 58), (24, 62), (3, 40), (0, 1), (3, 44), (3, 29), (3, 39), (3, 28), (6, 32), (6, 37), (6, 42), (3, 5), (3, 34), (3, 43), (3, 28), (3, 39), (0, 1), (3, 25), (6, 56), (5, 47), (6, 15), (5, 36), (5, 34), (5, 36), (5, 37), (19, 44), (5, 38), (19, 46), (5, 50), (5, 51), (5, 42), (5, 44), (5, 49), (11, 40), (11, 33), (11, 41), (11, 49), (11, 14), (11, 14), (9, 6), (6, 8), (3, 5), (0, 1), (3, 11), (0, 1), (3, 15), (3, 47), (24, 58), (24, 62), (3, 20), (6, 28), (9, 31), (6, 25), (9, 32), (6, 24), (9, 24), (9, 27), (6, 15), (9, 48), (3, 5), (0, 1), (3, 29), (3, 18), (0, 2), (0, 1), (0, 1), (0, 1), (0, 50), (0, 8), (0, 54), (0, 2), (3, 23), (3, 56), (3, 23), (3, 34), (3, 20), (3, 22), (0, 1), (3, 16), (3, 17), (0, 1), (3, 28), (3, 29), (0, 1), (3, 43), (3, 44), (0, 1), (3, 18), (0, 1), (6, 30), (15, 44), (15, 47), (12, 15), (6, 58), (6, 18), (0, 1), (6, 31), (9, 57), (9, 56), (9, 70), (12, 59), (9, 49), (6, 8), (6, 51), (0, 1), (6, 75), (6, 66), (0, 1), (6, 62), (0, 1), (6, 39), (6, 66), (0, 1), (6, 50), (3, 5), (0, 1), (3, 12), (3, 44), (3, 29), (3, 39), (0, 1), (3, 43), (3, 28), (3, 37), (3, 27), (6, 31), (6, 37), (6, 42), (3, 5), (3, 34), (3, 53), (3, 16), (0, 1), (3, 12), (3, 25), (6, 23), (6, 21), (11, 36), (11, 62), (11, 49), (11, 70), (11, 48), (6, 8), (6, 20), (3, 5), (2, 3), (3, 15), (3, 42), (3, 20), (6, 28), (9, 31), (6, 24), (9, 24), (9, 27), (6, 26), (9, 21), (6, 25), (9, 24), (6, 30), (9, 32), (6, 32), (9, 48), (9, 47), (9, 30), (12, 26), (9, 18), (12, 23), (12, 31), (22, 72), (22, 42), (12, 32), (9, 11), (6, 15), (9, 50), (3, 5), (0, 1), (3, 31), (3, 31), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 34), (0, 2), (3, 23), (3, 56), (3, 23), (3, 34), (3, 20), (3, 22), (0, 1), (3, 16), (3, 17), (0, 1), (3, 29), (3, 44), (0, 1), (3, 18), (0, 1), (6, 30), (15, 44), (15, 47), (12, 15), (6, 58), (6, 18), (0, 1), (6, 31), (9, 57), (9, 60), (6, 8), (6, 51), (0, 1), (6, 75), (6, 60), (0, 1), (6, 62), (0, 1), (6, 39), (6, 60), (6, 50), (0, 1), (3, 5), (0, 1), (3, 44), (3, 29), (3, 39), (0, 1), (3, 53), (3, 16), (0, 1), (3, 15), (3, 42), (3, 24), (6, 56), (3, 20), (6, 28), (9, 31), (6, 24), (9, 24), (9, 27), (6, 26), (9, 27), (19, 61), (9, 23), (6, 25), (9, 24), (6, 30), (9, 27), (19, 49), (9, 23), (6, 32), (9, 48), (9, 30), (10, 29), (20, 72), (12, 26), (9, 18), (12, 23), (12, 31), (22, 64), (12, 32), (9, 11), (6, 15), (9, 44), (3, 5), (0, 1), (3, 25), (3, 31), (0, 2), (0, 1), (0, 1), (0, 56), (0, 56), (0, 56), (0, 1), (0, 50), (0, 7), (0, 25), (0, 2), (3, 37), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 22), (0, 2), (3, 14), (3, 13), (6, 14), (6, 78), (8, 75), (8, 73), (8, 63), (4, 7), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 28), (0, 2), (3, 14), (3, 13), (6, 14), (6, 47), (6, 23), (3, 6), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 33), (0, 2), (3, 26), (3, 27), (0, 1), (3, 27), (8, 29), (8, 39), (0, 1), (6, 68), (9, 70), (9, 70), (9, 70), (9, 35), (6, 45), (6, 25), (9, 20), (12, 31), (22, 70), (22, 43), (9, 45), (12, 47), (9, 38), (9, 26), (12, 30), (22, 62), (22, 48), (22, 34), (6, 15), (9, 27), (19, 72), (20, 32), (9, 27), (19, 79), (19, 31), (9, 27), (19, 55), (19, 40), (9, 28), (19, 74), (19, 32), (19, 31), (6, 8), (3, 5), (0, 1), (3, 72), (6, 25), (16, 69), (16, 82), (16, 36), (16, 66), (3, 5), (3, 16), (3, 20), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 23), (0, 2), (3, 21), (13, 60), (13, 22), (13, 62), (13, 36), (13, 28), (3, 20), (3, 24), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 23), (0, 2), (3, 21), (13, 65), (13, 25), (3, 20), (3, 14), (3, 24), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 34), (0, 2), (2, 15), (4, 22), (10, 54), (10, 65), (10, 19), (4, 25), (4, 21), (4, 15), (2, 4), (2, 23), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 22), (0, 2), (3, 21), (13, 56), (13, 43), (13, 25), (3, 24), (3, 20), (3, 24), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 37), (0, 2), (3, 21), (13, 63), (13, 25), (3, 22), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 46), (0, 2), (3, 23), (6, 17), (6, 14), (6, 63), (6, 11), (6, 54), (6, 71), (6, 75), (6, 70), (6, 67), (6, 78), (6, 75), (6, 14), (6, 76), (6, 71), (6, 74), (6, 73), (6, 77), (6, 78), (6, 12), (6, 18), (6, 11), (6, 17), (6, 14), (6, 65), (6, 11), (6, 54), (6, 76), (6, 69), (6, 71), (6, 75), (6, 70), (6, 67), (6, 78), (6, 75), (6, 14), (6, 76), (6, 71), (6, 74), (6, 73), (6, 77), (6, 78), (6, 12), (6, 18), (0, 1), (3, 20), (3, 23), (6, 32), (6, 42), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 26), (0, 2), (3, 21), (13, 56), (13, 25), (3, 20), (3, 22), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 26), (0, 2), (3, 21), (13, 72), (13, 65), (13, 72), (13, 73), (13, 45), (3, 15), (3, 20), (0, 2), (0, 1), (0, 1), (0, 56), (0, 56), (0, 56), (0, 1), (0, 60), (3, 58), (3, 16), (0, 3), (0, 1), (0, 50), (0, 8), (0, 21), (0, 2), (3, 12), (3, 54), (3, 61), (6, 31), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 44), (0, 2), (3, 45), (6, 16), (9, 17), (9, 36), (9, 56), (9, 68), (9, 32), (6, 9), (6, 18), (6, 23), (3, 5), (0, 1), (2, 37), (2, 29), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 31), (0, 2), (3, 39), (3, 32), (3, 36), (3, 18), (0, 2), (0, 1), (0, 1), (0, 50), (0, 64), (3, 62), (3, 66), (3, 62), (3, 52), (0, 1), (3, 56), (3, 59), (0, 3), (0, 59), (0, 2), (0, 14), (3, 17), (3, 17), (3, 62), (3, 30), (3, 26), (3, 30), (3, 14), (0, 8), (3, 29), (0, 9), (0, 2), (0, 1), (0, 1), (0, 50), (0, 5), (2, 27), (0, 5), (0, 8), (0, 37), (0, 2), (3, 21), (3, 27), (0, 1), (3, 36), (3, 28), (3, 50), (3, 16), (0, 2), (0, 1), (0, 1), (0, 50), (0, 5), (2, 48), (0, 5), (0, 8), (0, 36), (0, 4), (3, 21), (3, 27), (0, 1), (3, 36), (3, 25), (3, 34), (0, 2), (0, 1), (0, 1), (0, 50), (0, 71), (3, 67), (3, 66), (3, 67), (0, 1), (3, 68), (3, 67), (3, 71), (3, 69), (3, 69), (3, 55), (0, 1), (3, 71), (3, 70), (3, 65), (3, 67), (3, 15), (0, 1), (3, 64), (3, 69), (3, 66), (0, 3), (0, 12), (0, 8), (0, 29), (0, 7), (0, 1), (0, 8), (0, 45), (0, 2), (0, 14), (3, 21), (3, 43), (3, 47), (3, 33), (0, 9), (0, 2), (0, 1), (0, 1), (0, 8), (0, 54), (0, 2), (0, 14), (3, 26), (3, 27), (0, 1), (3, 43), (3, 44), (0, 1), (3, 53), (3, 33), (0, 1), (3, 41), (3, 33), (0, 1), (3, 73), (0, 14), (4, 65), (0, 7), (3, 62), (6, 25), (3, 6), (0, 9), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 41), (0, 2), (0, 14), (3, 71), (4, 33), (4, 7), (3, 17), (0, 24), (3, 76), (4, 17), (4, 7), (3, 33), (6, 53), (3, 17), (0, 23), (0, 2), (0, 1), (0, 1), (0, 50), (0, 28), (0, 1), (0, 34), (3, 41), (0, 36), (3, 33), (0, 1), (0, 8), (0, 41), (0, 2), (3, 25), (3, 30), (3, 30), (3, 54), (3, 17), (0, 2), (0, 1), (0, 8), (0, 30), (17, 52), (0, 2), (3, 49), (3, 45), (3, 31), (3, 16), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 29), (0, 2), (3, 17), (3, 18), (3, 15), (3, 27), (0, 1), (3, 36), (0, 1), (3, 42), (6, 41), (0, 1), (3, 22), (6, 20), (9, 45), (9, 48), (9, 16), (6, 20), (9, 40), (9, 41), (9, 38), (9, 16), (6, 20), (9, 40), (9, 48), (9, 16), (3, 5), (0, 1), (3, 65), (6, 17), (6, 67), (16, 36), (6, 18), (6, 14), (3, 5), (3, 56), (6, 63), (16, 53), (6, 18), (6, 14), (3, 5), (3, 45), (6, 43), (9, 20), (9, 28), (19, 65), (19, 51), (9, 21), (9, 17), (6, 8), (3, 5), (3, 51), (6, 33), (6, 43), (9, 26), (18, 57), (18, 36), (9, 21), (9, 17), (6, 8), (3, 5), (3, 79), (6, 17), (6, 69), (16, 36), (6, 18), (6, 14), (3, 5), (3, 56), (6, 28), (5, 19), (6, 15), (5, 60), (11, 26), (5, 14), (5, 10), (6, 8), (3, 5), (3, 48), (8, 45), (6, 68), (16, 57), (6, 18), (6, 14), (3, 5), (0, 1), (3, 30), (6, 70), (9, 47), (6, 40), (3, 5), (0, 1), (3, 24), (0, 1), (6, 19), (9, 24), (9, 26), (9, 47), (12, 30), (22, 76), (22, 34), (12, 68), (30, 52), (12, 24), (12, 20), (9, 12), (9, 16), (0, 1), (6, 19), (9, 41), (9, 26), (9, 47), (12, 30), (22, 76), (22, 34), (12, 68), (30, 52), (12, 51), (12, 24), (12, 20), (9, 12), (9, 32), (12, 69), (22, 59), (12, 24), (12, 20), (9, 12), (9, 16), (0, 1), (6, 19), (9, 41), (9, 57), (9, 32), (12, 72), (22, 60), (12, 51), (12, 24), (12, 20), (9, 11), (9, 32), (12, 69), (22, 59), (12, 53), (12, 24), (12, 20), (9, 12), (9, 16), (0, 1), (6, 15), (9, 44), (9, 16), (3, 5), (0, 1), (3, 25), (6, 45), (6, 22), (6, 25), (3, 5), (0, 1), (3, 71), (3, 36), (3, 35), (3, 37), (3, 34), (0, 1), (3, 61), (3, 30), (6, 50), (6, 39), (6, 31), (9, 47), (9, 39), (6, 8), (3, 5), (0, 1), (3, 36), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 31), (0, 2), (3, 17), (3, 18), (3, 15), (3, 24), (3, 20), (3, 27), (0, 1), (3, 36), (0, 1), (3, 42), (6, 43), (0, 1), (3, 22), (3, 22), (6, 20), (9, 45), (9, 48), (9, 16), (6, 20), (9, 40), (9, 41), (9, 49), (12, 60), (15, 26), (9, 27), (9, 37), (9, 16), (6, 20), (9, 40), (9, 48), (9, 16), (3, 5), (0, 1), (3, 8), (3, 65), (6, 17), (6, 67), (16, 36), (6, 18), (6, 14), (3, 5), (3, 56), (6, 63), (16, 53), (6, 18), (6, 14), (3, 5), (3, 51), (6, 33), (6, 43), (9, 26), (18, 57), (18, 36), (9, 21), (9, 17), (6, 8), (3, 5), (3, 79), (6, 17), (6, 69), (16, 36), (6, 18), (6, 14), (3, 5), (3, 57), (6, 17), (6, 25), (16, 70), (16, 45), (6, 38), (3, 8), (3, 56), (6, 28), (4, 18), (6, 15), (8, 66), (18, 39), (8, 20), (8, 16), (6, 8), (3, 5), (3, 48), (8, 46), (6, 68), (16, 57), (6, 18), (6, 14), (3, 5), (0, 1), (3, 30), (6, 70), (9, 47), (6, 40), (3, 5), (0, 1), (3, 24), (0, 1), (6, 19), (9, 24), (9, 26), (9, 46), (12, 30), (22, 77), (22, 34), (12, 68), (30, 52), (12, 24), (12, 20), (9, 12), (9, 16), (0, 1), (6, 19), (9, 41), (9, 26), (9, 32), (12, 68), (22, 59), (12, 51), (12, 24), (12, 20), (9, 12), (9, 16), (0, 1), (6, 19), (9, 41), (9, 57), (9, 32), (12, 72), (22, 60), (12, 51), (12, 24), (12, 20), (9, 11), (9, 32), (12, 69), (22, 59), (12, 53), (12, 24), (12, 20), (9, 12), (9, 16), (0, 1), (6, 15), (9, 46), (9, 16), (3, 5), (0, 1), (3, 25), (6, 44), (6, 22), (6, 25), (3, 5), (0, 1), (3, 71), (3, 36), (3, 35), (3, 55), (3, 34), (0, 1), (3, 61), (3, 26), (6, 33), (9, 53), (9, 42), (9, 34), (12, 50), (12, 42), (9, 11), (6, 8), (3, 12), (6, 28), (6, 39), (6, 33), (9, 48), (9, 39), (6, 8), (3, 5), (3, 36), (0, 1), (3, 26), (6, 26), (9, 39), (3, 12), (6, 18), (6, 26), (9, 57), (9, 27), (19, 52), (19, 39), (3, 5), (0, 1), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 26), (0, 2), (3, 16), (3, 15), (3, 27), (0, 1), (3, 36), (0, 1), (3, 42), (6, 38), (0, 1), (3, 39), (3, 22), (6, 62), (6, 57), (6, 57), (3, 5), (0, 1), (3, 65), (6, 17), (6, 67), (16, 36), (6, 18), (6, 14), (3, 5), (3, 56), (6, 58), (16, 53), (6, 18), (6, 14), (3, 5), (3, 30), (6, 33), (6, 43), (9, 26), (18, 57), (18, 36), (9, 21), (9, 17), (6, 8), (3, 5), (0, 1), (3, 24), (0, 1), (6, 19), (9, 46), (12, 30), (22, 77), (22, 34), (12, 68), (30, 52), (12, 24), (12, 20), (9, 12), (9, 24), (9, 16), (0, 1), (6, 32), (9, 41), (9, 32), (12, 68), (22, 59), (12, 24), (12, 20), (9, 12), (9, 16), (0, 1), (6, 15), (9, 41), (9, 16), (3, 5), (0, 1), (3, 25), (6, 44), (6, 22), (6, 25), (3, 5), (0, 1), (3, 58), (3, 34), (3, 33), (0, 1), (3, 60), (3, 38), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 22), (0, 2), (3, 21), (0, 1), (4, 48), (4, 20), (4, 12), (4, 53), (4, 12), (4, 80), (4, 77), (4, 49), (4, 12), (4, 75), (4, 74), (4, 73), (4, 42), (4, 13), (4, 23), (3, 6), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 34), (0, 2), (3, 13), (6, 14), (6, 50), (6, 22), (6, 62), (6, 11), (6, 52), (6, 53), (6, 51), (6, 65), (6, 65), (6, 64), (6, 56), (6, 69), (6, 66), (6, 68), (6, 68), (6, 65), (6, 64), (6, 46), (6, 46), (6, 11), (6, 67), (6, 72), (6, 79), (6, 11), (6, 74), (6, 70), (6, 71), (0, 17), (6, 11), (0, 12), (6, 8), (0, 1), (6, 26), (6, 19), (3, 6), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 30), (0, 2), (3, 14), (6, 15), (6, 59), (6, 24), (0, 2), (0, 1), (0, 1), (0, 50), (0, 5), (2, 51), (2, 53), (2, 46), (0, 1), (2, 49), (2, 51), (2, 50), (2, 45), (0, 1), (2, 49), (2, 34), (0, 5), (0, 1), (0, 8), (3, 17), (6, 25), (6, 25), (3, 5), (3, 9), (0, 1), (0, 1), (0, 50), (0, 8), (0, 27), (0, 2), (3, 12), (0, 1), (3, 29), (3, 34), (3, 13), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 22), (0, 2), (3, 12), (0, 1), (3, 45), (3, 19), (3, 19), (3, 13), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 44), (0, 2), (3, 23), (6, 28), (6, 57), (6, 34), (6, 18), (3, 12), (6, 24), (6, 49), (6, 50), (6, 19), (3, 5), (0, 2), (0, 1), (0, 1), (0, 50), (0, 8), (0, 59), (0, 2), (3, 18), (3, 22), (0, 1), (3, 30), (3, 26), (6, 19), (6, 13), (6, 21), (9, 31), (9, 17), (9, 16), (9, 45), (9, 59), (9, 22), (12, 67), (12, 55), (12, 28), (12, 44), (9, 11), (6, 8), (3, 5), (0, 2), (0, 1), (0, 1), (0, 50), (0, 45), (0, 1), (0, 48), (0, 2), (3, 16), (3, 16), (3, 20), (3, 15), (3, 18), (0, 1), (3, 50), (3, 53), (7, 53), (7, 50), (6, 21), (0, 1), (3, 24), (3, 35), (3, 36), (3, 36), (3, 36), (3, 35), (3, 32), (3, 32), (3, 36), (3, 36), (3, 32), (3, 32), (3, 33), (3, 36), (3, 32), (3, 56), (0, 1), (3, 58), (3, 47), (0, 14), (0, 20), (3, 47), (0, 9), (0, 9), (0, 1), (3, 39), (3, 39), (0, 1), (3, 45), (3, 34), (3, 55), (6, 48), (0, 1), (0, 1), (3, 44), (8, 47), (3, 8), (3, 19), (3, 46), (3, 45), (3, 33), (6, 41), (0, 1), (0, 1), (3, 53), (3, 24), (3, 24), (3, 27), (3, 51), (6, 54), (6, 50), (6, 22), (6, 54), (9, 52), (3, 5), (0, 1), (0, 1), (3, 72), (3, 26), (6, 47), (0, 1), (0, 1), (3, 66), (3, 65), (3, 18), (0, 1), (3, 47), (8, 46), (6, 23), (0, 1), (3, 47), (8, 47), (8, 47), (8, 48), (6, 23), (6, 55), (3, 5), (0, 1), (0, 1), (3, 32), (3, 51), (6, 31), (6, 54), (9, 49), (12, 35), (15, 59), (15, 59), (15, 57), (15, 57), (15, 60), (15, 57), (15, 57), (15, 58), (15, 54), (15, 54), (15, 54), (15, 54), (15, 54), (15, 54), (15, 54), (15, 54), (15, 54), (15, 25), (15, 54), (15, 45), (15, 45), (25, 37), (25, 32), (15, 66), (35, 57), (25, 45), (25, 37), (25, 32), (12, 14), (9, 11), (6, 8), (3, 5), (3, 4), (3, 27), (3, 51), (6, 31), (6, 74), (6, 74), (6, 74), (6, 74), (6, 74), (6, 74), (6, 74), (6, 74), (6, 74), (6, 74), (6, 75), (6, 74), (6, 74), (6, 74), (6, 74), (6, 74), (6, 77), (9, 14), (9, 50), (12, 75), (12, 32), (12, 24), (9, 11), (3, 5), (0, 1), (3, 37), (3, 58), (6, 25), (0, 1), (3, 49), (6, 68), (16, 28), (6, 18), (3, 5), (0, 1), (3, 47), (6, 24), (0, 1), (3, 42), (0, 1), (3, 28), (6, 41), (6, 41), (0, 17), (6, 41), (0, 12), (3, 5), (0, 1), (3, 25), (5, 30), (8, 27), (5, 14), (8, 23), (8, 56), (11, 59), (11, 55), (11, 32), (11, 34), (8, 10), (5, 7), (3, 6), (3, 8), (0, 1), (3, 27), (6, 29), (6, 31), (9, 30), (6, 15), (9, 24), (9, 57), (12, 60), (12, 56), (12, 33), (12, 37), (9, 17), (6, 8), (6, 28), (9, 22), (9, 26), (6, 8), (3, 6), (0, 1), (3, 10), (6, 30), (6, 31), (9, 25), (6, 15), (9, 24), (9, 57), (8, 53), (12, 56), (12, 33), (12, 32), (5, 4), (6, 8), (6, 37), (9, 27), (11, 16), (11, 76), (11, 66), (9, 12), (9, 21), (9, 26), (6, 8), (3, 5), (0, 1), (3, 63), (6, 61), (3, 6), (3, 17), (3, 24), (6, 28), (6, 44), (6, 16), (6, 16), (3, 5), (0, 1), (3, 21), (0, 2), (0, 1), (0, 1), (0, 64), (0, 64), (0, 64)]
	]

	class MainPanel(wx.Panel):
	
		def __init__(me,parent):
			wx.Panel.__init__(me,parent)
			
			szr=wx.BoxSizer(wx.HORIZONTAL)
			me.SetSizer(szr)
			me.SetAutoLayout(True)
			
			me.textbars=[fm.TextBar(me) for i in range(len(Data))]		
			
			for i,textbar in enumerate(me.textbars):
				szr.AddSpacer(5)
				szr.Add(textbar,0,wx.EXPAND)
				textbar.set_line_dimensions(*unzip(Data[i]))
				textbar.events.Scroll += me.on_textbar_scroll
				
		def on_textbar_scroll(me,e):
			e.src.top_visible_line=e.line
			e.src.refresh_thumb()
			
	class MainFrame(wx.Frame):
	
		def __init__(me):
				
			wx.Frame.__init__(me,parent=None,size=(300,600))
			MainPanel(parent=me)
	
	try:
		"print a list of line indents and lengths"
		print [(fm.indent(s),len(s)) for s in open(sys.argv[1]).readlines()]
		if 0: print open(sys.argv[1]).readlines()
		for x in Data:
			print 'lines\t',len(x)
		sys.exit()
	except IndexError:
		pass
		
	settings['decorations']=('Silhouette',)
	app = wx.PySimpleApp()	frame = MainFrame()
	frame.Show()
	frame.Centre()	app.MainLoop()
